home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Tool Chest / Development Kits / MPW etc. / Debuggers / SADE / SADE 1.4a3 / SadeUserStartup•Extras < prev    next >
Encoding:
Text File  |  1992-07-10  |  4.8 KB  |  130 lines  |  [TEXT/sade]

  1. ##########################################################################################
  2. #    Symbolic Application Debugging Environment 1.4
  3. #
  4. #    copyright Apple Computer, Inc. 1987-1991
  5. #    All rights reserved.
  6. #
  7. ##########################################################################################
  8.  
  9. #Name of the window for 'value in context'
  10. Define __gValueInContextWindowName__
  11.  
  12. # Given a variable name, this routine displays it in a new window if the name of window
  13. # will be 32 chars or less
  14. PROC __PutValueInWindow__(__TheVarName__)
  15.     __gValueInContextWindowName__ := Concat(__ScratchDir__, __TheVarName__)
  16.  
  17.     Define __EvaledVar__ := CheckedEval(__TheVarName__,'Undefined or out of scope: ')
  18.  
  19.     Define __TopOfFile__
  20.     IF Length(__TheVarName__) < 33 THEN
  21.         Redirect __gValueInContextWindowName__
  22.         CheckValidLocalVars
  23.         PrettyPrintValue(__TheVarName__)
  24.         Redirect Pop
  25.         __TopOfFile__ := Selection(__gValueInContextWindowName__,0,0) # Puts cursor at top of window
  26.     ELSE
  27.         __gValueInContextWindowName__ := __gValueWindow__
  28.         Redirect Append __gValueInContextWindowName__
  29.         CheckValidLocalVars
  30.         PrettyPrintValue(__TheVarName__)
  31.         Redirect Pop
  32.     END
  33. END
  34.  
  35. # Given a selection (hopefully a field name) in a ShowValue2 window,
  36. # this routine returns the string 'ParentName.field'
  37. FUNC __FindVarName__(__TheVarName__)
  38.     IF ActiveWindow = __gValueWindow__ THEN
  39.         # If the selection is in the Value window,
  40.         # we can not guess which variable the user is talking about
  41.         Return __TheVarName__
  42.     END
  43.  
  44.     IF __GetDirectoryFromFullPath__(ActiveWindow) <> __ScratchDir__ THEN
  45.         # The selection is probably in the source code,
  46.         # we can not guess which variable the user is talking about
  47.         Return __TheVarName__
  48.     END
  49.     
  50.     # We will find the leaf name of the window
  51.     Define ParentName := __GetFileFromFullPath__(ActiveWindow)
  52.     # Append the field name to that of its parent struct
  53.     __TheVarName__ := Concat(ParentName, Concat('.', __TheVarName__))
  54.     Return __TheVarName__
  55. END
  56.  
  57. # Like Show Value, but try to qualify the selection with a parent name.
  58. # Also, open a new window if possible
  59. PROC __HandleShowValue2__(__Selection__)
  60.     CheckNullOrRunningTarget
  61.     __CheckNullSelection__(__Selection__)
  62.     Define __TheVarName__ := __FindVarName__(__Selection__)
  63.     __PutValueInWindow__(__TheVarName__)
  64.     Open __gValueInContextWindowName__
  65. END
  66.  
  67. PROC __HandleShowDereferencedValue2__(__Selection__)
  68.     CheckNullOrRunningTarget
  69.     __CheckNullSelection__(__Selection__)
  70.     Define __TheVarName__ := __FindVarName__(__Selection__)
  71.     __CheckPointer__(__TheVarName__)
  72.     __PutValueInWindow__(Concat(__TheVarName__,'^'))
  73.     Open __gValueInContextWindowName__
  74. END
  75.  
  76. PROC __SetValue__
  77.     CheckNullOrRunningTarget
  78.     Define __Selection__ := Selection(ActiveWindow)
  79.     __CheckNullSelection__(__Selection__)
  80.     Define __TheVarName__ := __FindVarName__(__Selection__)
  81.     # IF we can not display the value of the variable, we are not going to be able to set it
  82.     Define __EvaledVar__ := CheckedEval(__TheVarName__,'Could not evaluate left hand side :')
  83.     Define __Condition__ := Request(Concat(__TheVarName__, ' = ?'))
  84.     IF __Condition__ = '_CANCEL_' THEN
  85.         ABORT
  86.     END
  87.     Define __EvaledCondition__
  88.     Define __AssignmentExpr__
  89.     Define __EvaledAssignmentExpr__
  90.     IF __Condition__ = '' THEN
  91.         __Fail__('No value was specified, not modified.')
  92.     ELSE
  93.         # check for valid right hand side
  94.         __EvaledCondition__ := CheckedEval(__Condition__, 'Could not evaluate right hand side of assignment: ')
  95.  
  96.         # check for valid condition
  97.         __AssignmentExpr__ := Concat(Concat(__TheVarName__, ' := '), __Condition__)
  98.         __EvaledAssignmentExpr__ := CheckedEval(__AssignmentExpr__, 'Assignment failed.')
  99.     END
  100. END
  101.  
  102. PROC __ShowHandleObject__(__Object__)
  103.     CheckNullOrRunningTarget
  104.     __CheckPointer__(__Object__)
  105.     Define __OnceDeref__ := CheckedEval(Concat(__Object__,'^'),'Undefined/Out of scope: ')
  106.     __CheckPointer__(__OnceDeref__)
  107.     __PutValueInWindow__(Concat(__Object__, '^^'))
  108.     Open __gValueInContextWindowName__
  109. END
  110.  
  111. PROC __DoubleDeref__
  112.     CheckNullOrRunningTarget
  113.     Define __Handle__ := Selection(ActiveWindow)
  114.     __CheckNullSelection__(__Handle__)
  115.     Define __TheVarName__ := __FindVarName__(__Handle__)
  116.     __CheckPointer__(__TheVarName__)
  117.     Define __OnceDeref__ := CheckedEval(Concat(__TheVarName__,'^'),'Undefined/Out of scope: ')
  118.     __PutValueInWindow__(Concat(__TheVarName__,'^^'))
  119.     Open __gValueInContextWindowName__
  120. END
  121.  
  122. Addmenu 'Extras'  'Show Value In Context/2'              '__HandleShowValue2__(Selection(ActiveWindow))'    # Cmd-2
  123. Addmenu 'Extras'  'Show Dereferenced Value In Context/3'    '__HandleShowDereferencedValue2__(Selection(ActiveWindow))'    # Cmd-3
  124. Addmenu 'Extras'  'Set Value /='                        '__SetValue__'
  125. Addmenu 'Extras'  '(-'                 ''
  126. Addmenu 'Extras'  'Show **this/4'                        '__ShowHandleObject__("this")'    #For MacApp/C++ programmers
  127. Addmenu 'Extras'  'Show *this'                            '__HandleShowDereferencedValue2__("this")'    #For non-MacApp/C++ programmers
  128. Addmenu 'Extras'  'Twice Dereference Selection/5'        '__DoubleDeref__'
  129.  
  130.